package sindconsole.misc.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import sindconsole.misc.bean.DictItem;

import java.util.List;

@Mapper
public interface DictItemMapper extends BaseMapper<DictItem> {

    @Update("update dict_item set parent_id=#{parentId} where id=#{id}")
    int updateParentId(@Param("parentId") Long newParentId, @Param("id") long id);

    @Update("update dict_item set parent_id=#{newParentId} where parent_id=#{oldParentId}")
    int updateAllParentId(@Param("newParentId") Long newParentId, @Param("oldParentId") long oldParentId);

    @Select("<script>select * from dict_item where label in <foreach collection='labels' open='(' item='label' separator=',' close=')'>#{label}</foreach></script>")
    public List<DictItem> selectItemsByLabels( @Param("labels") List<String> labels);

}
